home *** CD-ROM | disk | FTP | other *** search
/ PC World Interactive 7 / PC World Interactive 7.iso / program / vbkontrol.exe / CSWSK10A.ZIP / generic.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-07-25  |  6.1 KB  |  205 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    Caption         =   "Form1"
  4.    ClientHeight    =   3195
  5.    ClientLeft      =   1695
  6.    ClientTop       =   2775
  7.    ClientWidth     =   5610
  8.    Height          =   3600
  9.    Left            =   1635
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   3195
  12.    ScaleWidth      =   5610
  13.    Top             =   2430
  14.    Width           =   5730
  15.    Begin Socket Socket2 
  16.       Backlog         =   1
  17.       Binary          =   -1  'True
  18.       Blocking        =   -1  'True
  19.       Broadcast       =   0   'False
  20.       BufferSize      =   0
  21.       HostAddress     =   ""
  22.       HostFile        =   ""
  23.       HostName        =   ""
  24.       Index           =   0
  25.       InLine          =   0   'False
  26.       Interval        =   0
  27.       KeepAlive       =   0   'False
  28.       Left            =   720
  29.       Linger          =   0
  30.       LocalPort       =   0
  31.       LocalService    =   ""
  32.       Peek            =   0   'False
  33.       Protocol        =   0
  34.       RecvLen         =   0
  35.       RemotePort      =   0
  36.       RemoteService   =   ""
  37.       ReuseAddress    =   0   'False
  38.       Route           =   -1  'True
  39.       SendLen         =   0
  40.       TabIndex        =   8
  41.       Timeout         =   0
  42.       Top             =   2520
  43.       Type            =   1
  44.       Urgent          =   0   'False
  45.    End
  46.    Begin Socket Socket1 
  47.       Backlog         =   1
  48.       Binary          =   -1  'True
  49.       Blocking        =   -1  'True
  50.       Broadcast       =   0   'False
  51.       BufferSize      =   0
  52.       HostAddress     =   ""
  53.       HostFile        =   ""
  54.       HostName        =   ""
  55.       InLine          =   0   'False
  56.       Interval        =   0
  57.       KeepAlive       =   0   'False
  58.       Left            =   120
  59.       Linger          =   0
  60.       LocalPort       =   0
  61.       LocalService    =   ""
  62.       Peek            =   0   'False
  63.       Protocol        =   0
  64.       RecvLen         =   0
  65.       RemotePort      =   0
  66.       RemoteService   =   ""
  67.       ReuseAddress    =   0   'False
  68.       Route           =   -1  'True
  69.       SendLen         =   0
  70.       TabIndex        =   7
  71.       Timeout         =   0
  72.       Top             =   2520
  73.       Type            =   1
  74.       Urgent          =   0   'False
  75.    End
  76.    Begin CommandButton Command1 
  77.       Caption         =   "&Connect"
  78.       Height          =   375
  79.       Left            =   2160
  80.       TabIndex        =   6
  81.       Top             =   2520
  82.       Width           =   1215
  83.    End
  84.    Begin TextBox Text3 
  85.       Enabled         =   0   'False
  86.       Height          =   855
  87.       Left            =   960
  88.       TabIndex        =   5
  89.       Top             =   1320
  90.       Width           =   3855
  91.    End
  92.    Begin TextBox Text2 
  93.       Enabled         =   0   'False
  94.       Height          =   285
  95.       Left            =   960
  96.       TabIndex        =   3
  97.       Top             =   840
  98.       Width           =   3855
  99.    End
  100.    Begin TextBox Text1 
  101.       Height          =   285
  102.       Left            =   960
  103.       TabIndex        =   1
  104.       Top             =   360
  105.       Width           =   2055
  106.    End
  107.    Begin Label Label3 
  108.       AutoSize        =   -1  'True
  109.       Caption         =   "Reply:"
  110.       Height          =   195
  111.       Left            =   360
  112.       TabIndex        =   4
  113.       Top             =   1320
  114.       Width           =   555
  115.    End
  116.    Begin Label Label2 
  117.       AutoSize        =   -1  'True
  118.       Caption         =   "Send:"
  119.       Height          =   195
  120.       Left            =   360
  121.       TabIndex        =   2
  122.       Top             =   840
  123.       Width           =   510
  124.    End
  125.    Begin Label Label1 
  126.       AutoSize        =   -1  'True
  127.       Caption         =   "Host:"
  128.       Height          =   195
  129.       Left            =   360
  130.       TabIndex        =   0
  131.       Top             =   360
  132.       Width           =   465
  133.    End
  134. Option Explicit
  135. Dim LastSocket As Integer
  136. Sub Command1_Click ()
  137.     Socket1.HostName = Trim$(Text1.Text)
  138.     Socket1.RemotePort = IPPORT_ECHO
  139.     Socket1.Action = SOCKET_CONNECT
  140. End Sub
  141. Sub Form_Load ()
  142.     Socket1.AddressFamily = AF_INET
  143.     Socket1.Protocol = IPPROTO_IP
  144.     Socket1.Type = SOCK_STREAM
  145.     Socket1.Binary = False
  146.     Socket1.BufferSize = 1024
  147.     Socket1.Blocking = False
  148.     Socket2(0).AddressFamily = AF_INET
  149.     Socket2(0).Protocol = IPPROTO_IP
  150.     Socket2(0).Type = SOCK_STREAM
  151.     Socket2(0).Blocking = False
  152.     Socket2(0).LocalPort = IPPORT_ECHO
  153.     Socket2(0).Action = SOCKET_LISTEN
  154.     LastSocket = 0
  155. End Sub
  156. Sub Form_Unload (Cancel As Integer)
  157.     Dim I As Integer
  158.     If Socket1.Connected Then Socket1.Action = SOCKET_CLOSE
  159.     If Socket2(0).Listening Then Socket2(0).Action = SOCKET_CLOSE
  160.     For I = 1 To LastSocket
  161.         If Socket2(I).Connected Then Socket2(I).Action = SOCKET_CLOSE
  162.     Next I
  163.     End
  164. End Sub
  165. Sub Socket1_Connect ()
  166.     Text2.Enabled = True
  167.     Text3.Enabled = True
  168. End Sub
  169. Sub Socket1_Read (DataLength As Integer, IsUrgent As Integer)
  170.     Socket1.RecvLen = DataLength
  171.     Text3.Text = Socket1.RecvData
  172. End Sub
  173. Sub Socket2_Accept (Index As Integer, SocketId As Integer)
  174.     Dim I As Integer
  175.     For I = 1 To LastSocket
  176.         If Not Socket2(I).Connected Then Exit For
  177.     Next I
  178.     If I > LastSocket Then
  179.         LastSocket = LastSocket + 1: I = LastSocket
  180.         Load Socket2(I)
  181.     End If
  182.     Socket2(I).AddressFamily = AF_INET
  183.     Socket2(I).Protocol = IPPROTO_IP
  184.     Socket2(I).Type = SOCK_STREAM
  185.     Socket2(I).Binary = True
  186.     Socket2(I).BufferSize = 1024
  187.     Socket2(I).Blocking = False
  188.     Socket2(I).Accept = SocketId
  189. End Sub
  190. Sub Socket2_Close (Index As Integer)
  191.     Socket2(Index).Action = SOCKET_CLOSE
  192. End Sub
  193. Sub Socket2_Read (Index As Integer, DataLength As Integer, IsUrgent As Integer)
  194.     Socket2(Index).RecvLen = DataLength
  195.     Socket2(Index).SendLen = DataLength
  196.     Socket2(Index).SendData = Socket2(Index).RecvData
  197. End Sub
  198. Sub Text2_KeyPress (KeyAscii As Integer)
  199.     If KeyAscii = 13 Then
  200.         Socket1.SendLen = Len(Text2.Text)
  201.         Socket1.SendData = Text2.Text
  202.         KeyAscii = 0: Text2.Text = ""
  203.     End If
  204. End Sub
  205.